/*
 * This class is for compositePattern method，it implements TransparentCompositePatternComponent,inside the operations,
 * it ask for  TransparentCompositePatternComponent.
 * 
 * Composite couldn't do any operation to its children because it have no child,so it will throw exception if client
 * ask for such method:add,update,remove.
 * 
 * Exception:
 * 		Exception e;
 * public:
 * 		public String operation(TransparentCompositePatternComponent c) ;
 * 		public String add(TransparentCompositePatternComponent c);
 * 		public String remove(TransparentCompositePatternComponent c);
 * 		public String update(TransparentCompositePatternComponent c); 
 */
package compositePattern;

public class TransparentCompositePatternLeaf implements TransparentCompositePatternComponent{

	/*
	 * (non-Javadoc)
	 * The leaf also need to override all the method of interface,and it will throw exception in some unsafe method 
	 * with some message,to make sure client would not do any error operations.
	 */
	@Override
	public String operation(TransparentCompositePatternComponent c) {
		return "I am the leaf of TransparentCompositePanttern";
	}

	@Override
	public String add(TransparentCompositePatternComponent c) throws Exception {
		throw new Exception("Leaf could't add component");
	}

	@Override
	public String remove(TransparentCompositePatternComponent c) throws Exception {
		throw new Exception("Leaf could't remove component");
	}

	@Override
	public String update(TransparentCompositePatternComponent c) throws Exception {
		throw new Exception("Leaf could't update component");
	}
}
